import time
import os
import random
from pathlib import Path
from progress.bar import  Bar


while True:
    work_start_time = time.time()
    with Bar('Working', max=50) as bar:
        counter = 0
        while time.time() - work_start_time < 3000:
            if counter == 60:
                bar.next()
                counter = 0
            time.sleep(1)
            counter += 1

    rest_start_time = time.time()
    p = Path('c:/Users/ming/Music/')
    audios = list(p.glob('**/*.mp3'))
    audios += list(p.glob('**/*.flac'))

    while time.time() - rest_start_time < 600:
        # rest time
        index = random.randint(0, len(audios)-1)
        cmd = 'ffplay -autoexit "{}"'.format(str(audios[index]))
        print(cmd)
        os.system(cmd)
